export function isAuth(tableName, key) {
  let role = localStorage.getItem("UserTableName");
  let menus =   [{"backMenu":[{"child":[{"appFrontIcon":"cuIcon-pay","buttons":["新增","查看","修改","删除"],
"menu":"学员","menuJump":"列表","tableName":"xueyuan"}],
"menu":"学员管理"},{"child":[{"appFrontIcon":"cuIcon-similar","buttons":["新增","查看","修改","删除"],
"menu":"教练","menuJump":"列表","tableName":"jiaolian"}],
"menu":"教练管理"},{"child":[{"appFrontIcon":"cuIcon-shop","buttons":["新增","查看","修改","删除"],
"menu":"车辆信息","menuJump":"列表","tableName":"cheliangxinxi"}],
"menu":"车辆信息管理"},
{"child":[{"appFrontIcon":"cuIcon-form","buttons":["新增","查看","修改","删除"],
"menu":"驾校信息","menuJump":"列表","tableName":"jiaxiaoxinxi"}],
"menu":"驾校信息管理"},{"child":[{"appFrontIcon":"cuIcon-full","buttons":["查看","修改","删除"],
"menu":"缴费信息","menuJump":"列表","tableName":"jiaofeixinxi"}],
"menu":"缴费信息管理"},{"child":[{"appFrontIcon":"cuIcon-similar","buttons":["查看","修改","删除"],
"menu":"驾校教练","menuJump":"列表","tableName":"jiaxiaojiaolian"}],
"menu":"驾校教练管理"},{"child":[{"appFrontIcon":"cuIcon-goods","buttons":["查看","修改","删除"],
"menu":"预约教练","menuJump":"列表","tableName":"yuyuejiaolian"}],
"menu":"预约教练管理"},
{"child":[{"appFrontIcon":"cuIcon-vip","buttons":["查看","修改","删除"],
"menu":"车辆分配","menuJump":"列表","tableName":"cheliangfenpei"}],
"menu":"车辆分配管理"},{"child":[{"appFrontIcon":"cuIcon-keyboard","buttons":["查看","修改"],
"menu":"关于我们","tableName":"aboutus"},{"appFrontIcon":"cuIcon-circle","buttons":["查看","修改"],
"menu":"系统简介","tableName":"systemintro"},{"appFrontIcon":"cuIcon-goods","buttons":["查看","修改","删除"],
"menu":"轮播图管理","tableName":"config"}],
"menu":"系统管理"}],"frontMenu":[{"child":[{"appFrontIcon":"cuIcon-discover","buttons":["查看","缴费"],
"menu":"驾校信息列表","menuJump":"列表","tableName":"jiaxiaoxinxi"}],
"menu":"驾校信息模块"},{"child":[{"appFrontIcon":"cuIcon-link","buttons":["查看","预约"],
"menu":"驾校教练列表","menuJump":"列表","tableName":"jiaxiaojiaolian"}],
"menu":"驾校教练模块"}],"hasBackLogin":"是","hasBackRegister":"否","hasFrontLogin":"否","hasFrontRegister":"否","roleName":"管理员","tableName":"users"},{"backMenu":[{"child":[{"appFrontIcon":"cuIcon-shop","buttons":["查看"],
"menu":"车辆信息","menuJump":"列表","tableName":"cheliangxinxi"}],
"menu":"车辆信息管理"},{"child":[{"appFrontIcon":"cuIcon-full","buttons":["查看","删除","支付"],
"menu":"缴费信息","menuJump":"列表","tableName":"jiaofeixinxi"}],
"menu":"缴费信息管理"},{"child":[{"appFrontIcon":"cuIcon-goods","buttons":["查看","删除"],
"menu":"预约教练","menuJump":"列表","tableName":"yuyuejiaolian"}],
"menu":"预约教练管理"},{"child":[{"appFrontIcon":"cuIcon-vip","buttons":["查看"],
"menu":"车辆分配","menuJump":"列表","tableName":"cheliangfenpei"}],
"menu":"车辆分配管理"},{"child":[{"appFrontIcon":"cuIcon-shop","buttons":["查看"],
"menu":"通知信息","menuJump":"列表","tableName":"tongzhixinxi"}],
"menu":"通知信息管理"}],"frontMenu":[{"child":[{"appFrontIcon":"cuIcon-discover","buttons":["查看","缴费"],
"menu":"驾校信息列表","menuJump":"列表","tableName":"jiaxiaoxinxi"}],
"menu":"驾校信息模块"},{"child":[{"appFrontIcon":"cuIcon-link","buttons":["查看","预约"],
"menu":"驾校教练列表","menuJump":"列表","tableName":"jiaxiaojiaolian"}],
"menu":"驾校教练模块"}],"hasBackLogin":"是","hasBackRegister":"否","hasFrontLogin":"是","hasFrontRegister":"是","roleName":"学员","tableName":"xueyuan"},{"backMenu":[{"child":[{"appFrontIcon":"cuIcon-shop","buttons":["查看"],
"menu":"车辆信息","menuJump":"列表","tableName":"cheliangxinxi"}],
"menu":"车辆信息管理"},{"child":[{"appFrontIcon":"cuIcon-similar","buttons":["新增","查看","修改","删除"],
"menu":"驾校教练","menuJump":"列表","tableName":"jiaxiaojiaolian"}],
"menu":"驾校教练管理"},{"child":[{"appFrontIcon":"cuIcon-goods","buttons":["查看","审核"],
"menu":"预约教练","menuJump":"列表","tableName":"yuyuejiaolian"}],
"menu":"预约教练管理"},{"child":[{"appFrontIcon":"cuIcon-vip","buttons":["查看"],
"menu":"车辆分配","menuJump":"列表","tableName":"cheliangfenpei"}],
"menu":"车辆分配管理"}],"frontMenu":[{"child":[{"appFrontIcon":"cuIcon-discover","buttons":["查看","缴费"],
"menu":"驾校信息列表","menuJump":"列表","tableName":"jiaxiaoxinxi"}],
"menu":"驾校信息模块"},{"child":[{"appFrontIcon":"cuIcon-link","buttons":["查看","预约"],
"menu":"驾校教练列表","menuJump":"列表","tableName":"jiaxiaojiaolian"}],
"menu":"驾校教练模块"}],"hasBackLogin":"是","hasBackRegister":"是","hasFrontLogin":"否","hasFrontRegister":"否","roleName":"教练","tableName":"jiaolian"}];
  for(let i=0;i<menus.length;i++){
    if(menus[i].tableName==role){
      for(let j=0;j<menus[i].frontMenu.length;j++){
          for(let k=0;k<menus[i].frontMenu[j].child.length;k++){
            if(tableName==menus[i].frontMenu[j].child[k].tableName){
              let buttons = menus[i].frontMenu[j].child[k].buttons.join(',');
              return buttons.indexOf(key) !== -1 || false
            }
          }
      }
    }
  }
  return false;
}

/**
 *  * 获取当前时间（yyyy-MM-dd hh:mm:ss）
 *   */
export function getCurDateTime() {
    let currentTime = new Date(),
    year = currentTime.getFullYear(),
    month = currentTime.getMonth() + 1 < 10 ? '0' + (currentTime.getMonth() + 1) : currentTime.getMonth() + 1,
    day = currentTime.getDate() < 10 ? '0' + currentTime.getDate() : currentTime.getDate(),
    hour = currentTime.getHours(),
    minute = currentTime.getMinutes(),
    second = currentTime.getSeconds();
    return year + "-" + month + "-" + day + " " +hour +":" +minute+":"+second;
}

/**
 *  * 获取当前日期（yyyy-MM-dd）
 *   */
export function getCurDate() {
    let currentTime = new Date(),
    year = currentTime.getFullYear(),
    month = currentTime.getMonth() + 1 < 10 ? '0' + (currentTime.getMonth() + 1) : currentTime.getMonth() + 1,
    day = currentTime.getDate() < 10 ? '0' + currentTime.getDate() : currentTime.getDate();
    return year + "-" + month + "-" + day;
}
